package com.deercrowing.takeaway.controller.admin;

import com.deercrowing.takeaway.common.model.Result;
import com.deercrowing.takeaway.service.WorkSpaceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.LocalTime;

@Slf4j
@Validated
@RestController
@RequestMapping("admin/workspace")
public class WorkSpaceController {

    @Autowired
    WorkSpaceService workSpaceService;

    @GetMapping("/businessData")
    public ResponseEntity businessData(){
        //获得当天的开始时间
        LocalDateTime begin = LocalDateTime.now().with(LocalTime.MIN);
        //获得当天的结束时间
        LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);

        return ResponseEntity.ok(Result.OK(workSpaceService.businessDataManage(begin,end)));
    }

    @GetMapping("/overviewOrders")
    public ResponseEntity OrderData(){
        return ResponseEntity.ok(Result.OK(this.workSpaceService.OrderViewManage()));
    }

    @GetMapping("/overviewDishes")
    public ResponseEntity DishData(){
        return ResponseEntity.ok(Result.OK(this.workSpaceService.DishViewManage()));
    }

    @GetMapping("/overviewSetmeals")
    public ResponseEntity SetmealData(){
        return ResponseEntity.ok(Result.OK(this.workSpaceService.SetmealViewManage()));
    }
}
